from options import VanillaOption
from process import BlackScholes
from analytical_formulas import bsm_vanilla



class AnalyticalEngine:
    def __init__(self):
        pass

    def cal_pv(self,spot, valuation_date,  option, process):
        if isinstance(process, BlackScholes):
            if isinstance(option, VanillaOption):
                strike = option.strike_price
                r = process.risk_free_rate
                q = process.dividend_yield
                vol = process.vol
                t = (option.maturity_date - valuation_date).days/365.0
                option_type = option.option_type
                notional = option.notional

                return bsm_vanilla(spot, strike, r, q, vol, t, option_type)*notional
        else:
            raise Exception("unsupported option type and process")



